﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Drawing;

namespace NamazVakti
{
    public enum VakitEnumeration : int
    {
        None = 0,
        Imsak = 1,
        Gunes = 2,
        Ogle = 3,
        Ikinki = 4,
        Aksam = 5,
        Yatsi = 6
    }

    public enum VakitDurumu
    {
        None,
        Gecti,
        Suan,
        Gelecek
    }

    public struct Vakit
    {
        public VakitEnumeration Type;
        public DateTime DateTime;
        public int Interval;

        Vakit(VakitEnumeration vakit, DateTime d, int interval)
        {
            Interval = interval;
            DateTime = d;
            Type = vakit;
        }

        public static Vakit Imsak = new Vakit(VakitEnumeration.Imsak, DateTime.Now, 1);
        public static Vakit Gunes = new Vakit(VakitEnumeration.Gunes, DateTime.Now, 1);
        public static Vakit Ogle = new Vakit(VakitEnumeration.Ogle, DateTime.Now, 1);
        public static Vakit Ikinki = new Vakit(VakitEnumeration.Ikinki, DateTime.Now, 1);
        public static Vakit Aksam = new Vakit(VakitEnumeration.Aksam, DateTime.Now, 1);
        public static Vakit Yatsi = new Vakit(VakitEnumeration.Yatsi, DateTime.Now, 1);
        public static Vakit Belirsiz = new Vakit(VakitEnumeration.None, DateTime.MinValue, 1);

        public Color GetBackColor(VakitEnumeration type)
        {
            Color pastBackColor = SystemColors.InactiveBorder,
             currentBackColor = Color.OrangeRed,
             defaultBackColor =SystemColors.Window;

            if (this == type)
                return currentBackColor;
            else if (this.Type > type)
                return pastBackColor;
            else
                return defaultBackColor;
        }

        public Color GetForeColor(VakitEnumeration type)
        {
            Color defaultForeColor = SystemColors.WindowText,
             pastForeColor = SystemColors.WindowText,
             currentForeColor = SystemColors.Info;

            if (this == type)
                return currentForeColor;
            else if (this.Type > type)
                return pastForeColor;
            else
                return defaultForeColor;
        }

        #region Operators

        public static implicit operator string(Vakit vakit)
        {
            return vakit.DateTime.ToString("HH:mm");
        }

        public static implicit operator DateTime(Vakit vakit)
        {
            return vakit.DateTime;
        }

        public static bool operator <(Vakit v, DateTime d)
        {
            return v.DateTime.TimeOfDay < d.TimeOfDay;
        }

        public static bool operator >(Vakit v, DateTime d)
        {
            return v.DateTime.TimeOfDay > d.TimeOfDay;
        }

        public static bool operator ==(Vakit v, DateTime d)
        {
            return v.DateTime.TimeOfDay == d.TimeOfDay;
        }

        public static bool operator !=(Vakit v, DateTime d)
        {
            return v.DateTime.TimeOfDay == d.TimeOfDay;
        }

        public static bool operator ==(Vakit v, VakitEnumeration e)
        {
            return v.Type == e;
        }

        public static bool operator !=(Vakit v, VakitEnumeration e)
        {
            return v.Type == e;
        }

        public static bool operator >=(Vakit v, DateTime d)
        {
            return v.DateTime.TimeOfDay >= d.TimeOfDay;
        }

        public static bool operator <=(Vakit v, DateTime d)
        {
            return v.DateTime.TimeOfDay <= d.TimeOfDay;
        }

        #endregion //operators

        //public override string ToString()
        //{
        //    return DateTime.ToString("HH:mm");
        //}
    }
}
